const address = require('../../model/Address');

!(async () => {
    //创建收货地址
    // const addressList = await address.create({
    //     username: '张三',
    //     city: '湖南长沙',
    //     department: '雨花区',
    //     houseNumber: 'A座101',
    //     name: '张三',
    //     phone: 18811881188
    // })
    // const addressList = await address.create({
    //     username: '张三',
    //     city: '上海',
    //     department: '黄浦区',
    //     houseNumber: 'B座102',
    //     name: '李四',
    //     phone: 18811881111
    // })
    //查询地址列表
    // const addressList = await address.find().sort({ updatedAt: -1 })
    //查询单个地址
    // const id = '63d0ef6b36a72443348a3c0d';
    // const addressList = await address.findById(id);
    //修改地址
    const id = '63d0efab94a43ec6aa652e8a';
    const newData = {
        city: '湖南长沙',
        department: '岳麓区',
        houseNumber: 'B座1101',
        name: '李四',
        phone: 18811882222
    }
    const addressList = await address.findOneAndUpdate({
        _id: id,
        username: '张三'
    },
        newData,
        {
            new: true
        }
    )
    console.log(addressList);
})()